package org.java.upload.conf;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.OSSClientBuilder;
import jdk.nashorn.internal.ir.ReturnNode;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author WHQ
 * @version 1.0
 * @date 2022-3-5 0005 下午 2:17
 */
@Configuration
public class UploadConfig {
    //存储地址
    @Value("${alibaba.endpoint}")
    private String endpoint;
    //用户名
    @Value("${alibaba.accessKeyId}")
    private String accessKeyId;
    //密码
    @Value("${alibaba.accessKeySecret}")
    private String accessKeySecret;
    //空间名称
    @Value("${alibaba.bucketName}")
    private String bucketName;
    //文件访问路径的前缀
    @Value("${alibaba.urlPrefix}")
    private String urlPrefix;
    //得到文件存放的位置
    @Value("${whq.upload}")
    private String path;
    @Bean
    public OSS ossClient(){
        OSS ossClient=new OSSClientBuilder().build(endpoint,accessKeyId,accessKeySecret);
        return ossClient;
    }

    public String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }

    public String getAccessKeyId() {
        return accessKeyId;
    }

    public void setAccessKeyId(String accessKeyId) {
        this.accessKeyId = accessKeyId;
    }

    public String getAccessKeySecret() {
        return accessKeySecret;
    }

    public void setAccessKeySecret(String accessKeySecret) {
        this.accessKeySecret = accessKeySecret;
    }

    public String getBucketName() {
        return bucketName;
    }

    public void setBucketName(String bucketName) {
        this.bucketName = bucketName;
    }

    public String getUrlPrefix() {
        return urlPrefix;
    }

    public void setUrlPrefix(String urlPrefix) {
        this.urlPrefix = urlPrefix;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }
}
